<?php

namespace App\Http\Requests\airline\base;

use App\Http\ValidateResult;
use Illuminate\Support\Facades\Validator;

trait CompanyRequest
{
    public static function add_check(array $params): ValidateResult {
        $validator = Validator::make($params, [
            'agent_id' => 'required|integer',
            'short_name' => 'required',
            'name' => 'required',

        ], [
            'agent_id.required' => '请选择代理商',
            'short_name.required' => '请填写航空公司简称',
            'name.required' => '请填写航空公司全称',
        ]);

        if ($validator->fails()) {
            return ValidateResult::error($validator->errors()->first());
        }
        return ValidateResult::correct();
    }

}
